#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>

#include "sdkmanager.h"

namespace Ui {
class MainWindow;
}

//==================================================================================================
// 
//==================================================================================================
class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(const std::string& user_id, SdkManager* sdk_mgr, QWidget *parent = nullptr);
    ~MainWindow();

    void Init();

protected:
	void resizeEvent(QResizeEvent* event) override;
    void moveEvent(QMoveEvent* event) override;

private:
    bool OnIncomingCall(const std::string& call_type, const std::string& user_id,
                        const std::string& call_id);
    void OnCallStateChanged(const std::string& call_id, CallState state);
    void OnAddUser(const std::string& user_id);
    void OnRemoveUser(const std::string& user_id);
    void OnStartPublishNotify(const std::string& user_id, const MediaInfo& media);
    void OnStopPublishNotify(const std::string& user_id, const MediaInfo& media);
    void OnStartSubscribeResult(const std::string& user_id, const MediaInfo& media, bool result);
    void OnStopSubscribeResult(const std::string& user_id, const MediaInfo& media, bool result);
    void OnStartPublishResult(const MediaInfo& media, bool result);
    void OnStopPublishResult(const MediaInfo& media, bool result);

private slots:
    void OnCallBtnClicked();
    void OnPubCamBtnClicked();
    void OnPubMicBtnClicked();

private:
    Ui::MainWindow *ui;
    std::string m_user_id;
    SdkManager* m_sdk_mgr;

    bool m_pub_cam = false;
    bool m_pub_mic = false;
    bool m_calling = false;

    MediaInfo m_cam_media;
    MediaInfo m_mic_media;
};

#endif // MAINWINDOW_H
